package top.oneit.jdownload.test.table;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import java.net.URL;

/**
 * @author lingkang
 * @date 2021/12/12
 */
public class MyTable extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        Button button=new Button("update");
        VBox vBox = loadXML("/fxml/test/table.fxml");
        vBox.getChildren().add(button);
        button.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {

            }
        });
        primaryStage.setScene(new Scene(vBox));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

    public static <T> T loadXML(String path) {
        URL resource = MyTable.class.getResource(path);
        FXMLLoader fxmlLoader = new FXMLLoader(resource);
        try {
            return fxmlLoader.load();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
